package Text15;

import java.util.Scanner;

public class Main {
    //    第一行包含整数 n,m,q。接下来 n行，每行包含 m个整数，表示整数矩阵。
//    接下来 q行，每行包含 5个整数 x1,y1,x2,y2,c，表示一个操作。
    static int N = 1010, n, m, q;
    static int[][] b = new int[N][N];
    static int[][] arr = new int[N][N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        q = in.nextInt();
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                arr[i][j] = in.nextInt();
                insert(i, j, i, j, arr[i][j]);
            }
        }
        while (q-- > 0) {
            int x1 = in.nextInt();
            int y1 = in.nextInt();
            int x2 = in.nextInt();
            int y2 = in.nextInt();
            int c = in.nextInt();
            insert(x1, y1, x2, y2, c);
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                arr[i][j] = b[i][j] + arr[i - 1][j] + arr[i][j - 1] + arr[i - 1][j - 1];
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                System.out.print(arr[i][j] + " ");
            }
            System.out.println();
        }
    }

    private static void insert(int x1, int y1, int x2, int y2, int c) {
        b[x1][y1] += c;
        b[x2 + 1][y1] -= c;
        b[x1][y2 + 1] -= c;
        b[x2 + 1][y2 + 1] += c;
    }
}
